package com.insuremonitor.system.service.impl;

import com.insuremonitor.common.core.domain.AjaxResult;
import com.insuremonitor.common.utils.DateUtils;
import com.insuremonitor.system.domain.FrontInsureConfigDeduction;
import com.insuremonitor.system.mapper.FrontInsureConfigDeductionMapper;
import com.insuremonitor.system.service.IFrontInsureConfigDeductionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 保险信息免赔Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-11-21
 */
@Service
public class FrontInsureConfigDeductionServiceImpl implements IFrontInsureConfigDeductionService 
{
    @Autowired
    private FrontInsureConfigDeductionMapper frontInsureConfigDeductionMapper;

    /**
     * 查询保险信息免赔
     * 
     * @param deductionId 保险信息免赔主键
     * @return 保险信息免赔
     */
    @Override
    public FrontInsureConfigDeduction selectFrontInsureConfigDeductionByDeductionId(Long deductionId)
    {
        return frontInsureConfigDeductionMapper.selectFrontInsureConfigDeductionByDeductionId(deductionId);
    }

    /**
     * 查询保险信息免赔列表
     * 
     * @param frontInsureConfigDeduction 保险信息免赔
     * @return 保险信息免赔
     */
    @Override
    public List<FrontInsureConfigDeduction> selectFrontInsureConfigDeductionList(FrontInsureConfigDeduction frontInsureConfigDeduction)
    {
        frontInsureConfigDeduction.setStatus("1");
        return frontInsureConfigDeductionMapper.selectFrontInsureConfigDeductionList(frontInsureConfigDeduction);
    }

    /**
     * 新增保险信息免赔
     * 
     * @param frontInsureConfigDeduction 保险信息免赔
     * @return 结果
     */
    @Override
    public AjaxResult insertFrontInsureConfigDeduction(FrontInsureConfigDeduction frontInsureConfigDeduction)
    {
        frontInsureConfigDeduction.setCreateTime(DateUtils.getNowDate());
        int i = frontInsureConfigDeductionMapper.insertFrontInsureConfigDeduction(frontInsureConfigDeduction);
        if(i>0){
            return AjaxResult.success("操作成功",frontInsureConfigDeduction.getDeductionId());
        }else {
            return AjaxResult.error("操作失败");
        }
    }

    /**
     * 修改保险信息免赔
     * 
     * @param frontInsureConfigDeduction 保险信息免赔
     * @return 结果
     */
    @Override
    public int updateFrontInsureConfigDeduction(FrontInsureConfigDeduction frontInsureConfigDeduction)
    {
        frontInsureConfigDeduction.setUpdateTime(DateUtils.getNowDate());
        return frontInsureConfigDeductionMapper.updateFrontInsureConfigDeduction(frontInsureConfigDeduction);
    }

    /**
     * 批量删除保险信息免赔
     * 
     * @param deductionIds 需要删除的保险信息免赔主键
     * @return 结果
     */
    @Override
    public int deleteFrontInsureConfigDeductionByDeductionIds(Long[] deductionIds)
    {
        return frontInsureConfigDeductionMapper.deleteFrontInsureConfigDeductionByDeductionIds(deductionIds);
    }

    /**
     * 删除保险信息免赔信息
     * 
     * @param deductionId 保险信息免赔主键
     * @return 结果
     */
    @Override
    public int deleteFrontInsureConfigDeductionByDeductionId(Long deductionId)
    {
        return frontInsureConfigDeductionMapper.deleteFrontInsureConfigDeductionByDeductionId(deductionId);
    }
}
